<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../style/fjol_style.css"/>
		<link rel="stylesheet" type="text/css" href="../style/xol_style.css"/>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav newbgRed">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">楼盘相册</h1>
		</header>
		<div class="mui-content">
		    <div class="mui-scroll-wrapper">
		        <div class="mui-scroll" style="top: 40px;">
		            <!--这里放置真实显示的DOM内容-->
		            <ul class="mui-list-unstyled" id="photoList">
		            	
		            </ul>
		        </div>
		    </div>
		    
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-2.1.0.js"></script>
		<script src="../js/jquery.tmpl.min.js"></script>
		<script src="../js/xzx.open.js"></script>
		<script id="photoListTmpl" type="text/x-jquery-tmpl">
			<li id="${id}" class="bg-white p10 pt10">
        		<p>${name}</p>
        		<ul class="mui-list-unstyled photoImg">
        			{{tmpl($data) '#photoImgTmpl'}}
        		</ul>
        	</li>
		</script>
		<script id="photoImgTmpl" type="text/x-jquery-tmpl">
			{{each photoList}}
			<li>
				<img src="${fullUrl}" />
			</li>
			{{/each}}
		</script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function(){
				var wv = plus.webview.currentWebview();
//				console.log(wv.albumList.length);
				var albumlist = wv.albumList;
				$('#photoListTmpl').tmpl(albumlist).appendTo('#photoList');
				var liWidth = $('.photoImg li').width();
				$('.photoImg li').height(liWidth);
				var liHeight = $('.photoImg li').height();
				
				var imgObj = $('.photoImg li img');
				imgObj.each(function(){
					$(this).load(function(){
						setImgWidthHeight('.photoImg li img',liWidth,liHeight);
					});
				});
				
				mui('.photoImg').on('tap','li',function(){
					var parentLi = $(this).parents('li');
					var parentLi_id = parentLi.index();
//					console.log(parentLi_id);
					openWindowWithPage('newHouse_photoBig',{
						albumlist:albumlist,
						liIndex:parentLi_id
					});
				});
				
				
			});
			function setImgWidthHeight(imgobj,boxWidth,boxHeight){
				var boxRate = boxWidth/boxHeight;	//外框比例大小
				$(imgobj).each(function(){
					var imgWidth = $(this).width();
					var imgHeight = $(this).height();
					var imgRate = imgWidth/imgHeight;	//图片自身比例大小
					if(imgRate>boxRate){
						$(this).css('width',boxWidth);
						var marginTop = (boxHeight-$(this).height())/2;
						$(this).css('margin-top',marginTop);
					}else{
						$(this).css('height',boxHeight);
						var marginLeft = (boxWidth-$(this).width())/2;
						$(this).css('margin-left',marginLeft);
					}
				})
				
			}
			
			function clickGallery() {	//获取手机相册

				plus.gallery.pick(function(path) {
//					console.log(path);
				}, function(e) {
//					console.log("取消选择图片");
				}, {
					filter: "image"
				});}
			
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			});
		</script>
	</body>

</html>